<link rel="stylesheet"
      href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/css/bootstrap-select.min.css"
      rel="external nofollow">
<div id="pad-wrapper" class="new-user">

    <div class="row-fluid header">
        <h3>分销商品的添加/编辑</h3>
    </div>


    <div class="row-fluid form-wrapper">
        <!-- left column -->
        <div class="span9 with-sidebar">
            <div class="container">
                <form class="new_user_form form-horizontal required-validate" action="/distribution/deal" method="post"
                      enctype="multipart/form-data"  >

                    <div class="field-box"></div>
                    <input type="hidden" name="distribution_id" value="<?php if(isset($info['distribution_id'])){echo $info['distribution_id'];}?>">
                    <div class="control-group form-group span12" id="product_id">
                        <label class="control-label" for="product_id">分销商品:</label>
                        <div class="controls  col-lg-5">
                            <select name="product_id">
                                <option>请选择产品</option>
                                <?php foreach ($product_list as $v): ?>
                                    <option value="<?= $v['product_id'] ?>"
                                    <?php if(isset($info['product_id'])&&$v['product_id']==$info['product_id']){?>
                                        selected="selected"
                                    <?php }?>
                                    ><?= $v['product_name'] ?></option>
                                <?php endforeach; ?>
                            </select>
                        </div>
                    </div>


                    <div class="control-group form-group span12" >
                        <label class="control-label" for="distribution_price">售价:</label>
                        <div class="controls col-lg-5">
                            <input type="text" class="form-control" id="distribution_price" name="distribution_price"
                                   placeholder="请输入..." value="<?php if(isset($info['distribution_price'])){echo $info['distribution_price'];}?>" />
                        </div>
                    </div>

                    <div class="control-group form-group span12">
                        <label class="control-label" for="first_discount">首次购买折扣:</label>
                        <div class="controls col-lg-5">
                            <input type="text" class="form-control" id="first_discount" name="first_discount"
                                   placeholder="请输入..." value="<?php if(isset($info['first_discount'])){echo $info['first_discount'];}?>" />
                        </div>
                    </div>

                    <div class="control-group form-group span12">
                        <label class="control-label" for="level_1">一级分成比例:</label>
                        <div class="controls col-lg-5">
                            <input type="text" class="form-control" id="level_1" name="level_1"
                                   placeholder="请输入..." value="<?php if(isset($info['level_1'])){echo $info['level_1'];}?>" />
                        </div>
                    </div>

                    <div class="control-group form-group span12">
                        <label class="control-label" for="level_2">二级分成比例:</label>
                        <div class="controls col-lg-5">
                            <input type="text" class="form-control" id="level_2" name="level_2"
                                   placeholder="请输入..."  value="<?php if(isset($info['level_2'])){echo $info['level_2'];}?>"/>
                        </div>
                    </div>

                    <div class="control-group form-group span12">
                        <label class="control-label" for="level_3">三级分成比例:</label>
                        <div class="controls col-lg-5">
                            <input type="text" class="form-control" id="level_3" name="level_3"
                                   placeholder="请输入..."  value="<?php if(isset($info['level_3'])){echo $info['level_3'];}?>" />
                        </div>
                    </div>




                    <div class="control-group form-group span12" id="first_img">
                        <label class="control-label" for="level_3">添加图片:</label>
                        <div class="controls col-lg-5">
                            <input type="file" class="file" name="image_data[]" accept="image/*">
                            <input type="button" id="add_input" class="btn-glow primary" value="增加">
                        </div>
                    </div>


                    <div class="span12 field-box"></div>
                    <div class="control-group form-group span12 actions">
                        <label class="control-label" for="submit" class="control-label"></label>
                        <div class="controls col-lg-5">
                            <input type="submit" class="btn-glow primary" id="submit" value="提交"/>
                            <input type="reset" class="btn-glow primary" value="取消"/>
                        </div>
                    </div>
                </form>
            </div>

            <div class="control-group form-group span12" style="display: none" id="is_clone">
                <label class="control-label" for="level_3">添加图片:</label>
                <div class="controls col-lg-5">
                    <input type="file" class="file" name="image_data[]" accept="image/*">
                    <input type="button"  value="删除" class="btn-glow" onclick="del_self(this)">
                </div>
            </div>

        </div>


        <!-- side right column -->
        <div class="span3 form-sidebar pull-right"></div>
    </div>
</div>
<script>
//点击添加
$('#add_input').click(function () {
    $('#first_img').after($('#is_clone').clone().removeAttr('style').removeAttr('id'));
});

//删除图片
    function    del_self(obj){
        $(obj).parent().parent().remove();
    }
</script>
